﻿#include "SEAJunctionUserDefSelectDialog.h"
#include "ui_SEAJunctionUserDefSelectDialog.h"

#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsPhysics.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsSpectraManager.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsAbstractSpectra.h"

namespace GUI
{
    SEAJunctionUserDefSelectDialog::SEAJunctionUserDefSelectDialog(QWidget * parent) :
        GUIDialogBase(parent)
    {
        _ui = new Ui::SEAJunctionUserDefSelectDialog();
        _ui->setupUi(this);

        this->setWindowTitle(tr("Set All"));

        _ui->comboBox->addItem("Analytical", -2);
        if (_physics == nullptr && _physics->getFITKAcousticsSpectraManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractSpectra* specData :
            _physics->getFITKAcousticsSpectraManager()->getSpectraByType(Acoustics::FITKAcousticsAbstractSpectra::AcousticsSpectraType::Coupling))
        {
            if (specData == nullptr)continue;
            _ui->comboBox->addItem(specData->getDataObjectName(), specData->getDataObjectID());
        }

        _ui->comboBox->setCurrentIndex(0);
    }

    SEAJunctionUserDefSelectDialog::~SEAJunctionUserDefSelectDialog()
    {
        if (_ui) {
            delete _ui;
            _ui = nullptr;
        }
    }

    int SEAJunctionUserDefSelectDialog::getCurrentData()
    {
        return _ui->comboBox->currentData().toInt();
    }

    void SEAJunctionUserDefSelectDialog::on_pushButton_Ok_clicked()
    {
        this->accept();
    }

    void SEAJunctionUserDefSelectDialog::on_pushButton_Cancel_clicked()
    {
        this->reject();
    }
}

